package net.lab1024.sa.admin.module.business.school.room.controller;

import net.lab1024.sa.admin.module.business.school.room.domain.form.RoomAddForm;
import net.lab1024.sa.admin.module.business.school.room.domain.form.RoomQueryForm;
import net.lab1024.sa.admin.module.business.school.room.domain.form.RoomUpdateForm;
import net.lab1024.sa.admin.module.business.school.room.domain.vo.RoomVO;
import net.lab1024.sa.admin.module.business.school.room.service.RoomService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 房间 Controller
 *
 * @Author ZouYang
 * @Date 2024-12-28 12:10:44
 * @Copyright ZouYang
 */

@RestController
@Tag(name = "房间")
public class RoomController {

    @Resource
    private RoomService roomService;

    @Operation(summary = "分页查询 @author ZouYang")
    @PostMapping("/room/queryPage")
    @SaCheckPermission("room:query")
    public ResponseDTO<PageResult<RoomVO>> queryPage(@RequestBody @Valid RoomQueryForm queryForm) {
        return ResponseDTO.ok(roomService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author ZouYang")
    @PostMapping("/room/add")
    @SaCheckPermission("room:add")
    public ResponseDTO<String> add(@RequestBody @Valid RoomAddForm addForm) {
        return roomService.add(addForm);
    }

    @Operation(summary = "更新 @author ZouYang")
    @PostMapping("/room/update")
    @SaCheckPermission("room:update")
    public ResponseDTO<String> update(@RequestBody @Valid RoomUpdateForm updateForm) {
        return roomService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author ZouYang")
    @PostMapping("/room/batchDelete")
    @SaCheckPermission("room:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return roomService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author ZouYang")
    @GetMapping("/room/delete/{id}")
    @SaCheckPermission("room:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return roomService.delete(id);
    }
}
